
clear

import delimited C:\Users\karti\Documents\Data\regressions\population_full.csv

save "C:\Users\karti\Documents\Data\regressions\population_control.dta", replace

clear

import delimited using "C:\Users\karti\Documents\Data\regressions\all_agri_data_CPI_2004_05.csv"

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\procurement_production.dta"

*keep if _m==3

drop _m

foreach var of varlist marketing_reform date{

replace `var'= `var'[_n+2] if `var'==.
}

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\population_control.dta"

*keep if _m==3

drop _m

gen real_income_per_cult_1 = (real_farm_1_crore*10000000)/(cultivators_united)


merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\DBcontrols.dta"
drop if _m==1
drop _m

replace date=0 if date==.

cd "C:\Users\karti\Documents\Data\regressions\paper_2"

gen post_dif = (year>=date) 

gen interact1 = 0
replace interact1 = marketing_reform*post_dif




tab state, gen(st)
gen t1 =  year - 2000
forvalues j = 1/18 {
*linear
gen st_`j'=st`j'*t1
}

gen interact2 = 0
replace interact2=chand_reform*post_dif

egen state_id = group(state)

keep if real_income_per_cult_1!=.

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\DBcontrols.dta"
*drop if _m==1
drop _m



save "C:\Users\karti\Documents\Data\regressions\paper_2\data_for_regs.dta", replace

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\productivity.dta"
drop _m


gen fci_tot=(tot_procurement>0)

foreach var of varlist rice_productivity wheat_productivity wheat_procurement_proportion rice_procurement_proportion{
replace `var'=0 if `var'==.
}

global macro_controls "pop_full_new agrvad0405_crore"

global agri_controls "rice_prod wheat_prod no_agri_worker_united Wheat Rice wheat_procurement_proportion rice_procurement_proportion rice_productivity wheat_productivity"

keep if real_income_per_cult_1!=.

gen ln_inc = ln(real_income_per_cult_1)

**Replicating DB results
*keep if real_income_per_cult_1>=0
gen income_thousand = (real_income_per_cult_1)/1000


*reg income_thousand interact1 i.year i.state_id

areg ln_inc interact1 i.year , cluster(state) absorb(state)
outreg2 using ddln.xls, replace  ctitle("Marketing Reform") keep(interact1) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, NO, State Specific Linear Time Trend, NO) nocons


areg  ln_inc interact1 i.year $macro_controls, cluster(state) absorb(state)
outreg2 using ddln.xls, append  ctitle("DD Marketing Reform") keep(interact1) addtext(State FE, YES, Year FE, YES, Demographic Controls, YES, Agriculture Controls, NO, State Specific Linear Time Trend, NO) nocons



areg ln_inc  interact1 $macro_controls $agri_controls i.year, cluster(state) absorb(state)
outreg2 using ddln.xls, append  ctitle("DD Marketing Reform") keep(interact1) addtext(State FE, YES, Year FE, YES, Demographic Controls, YES, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

tabulate round, generate(yr)
cgmwildboot ln_inc  interact1 post_dif marketing_reform Rice Wheat pop_full_new agrvad0405_crore yr* rice_prod wheat_prod no_agri_worker_united wheat_procurement_proportion rice_procurement_proportion rice_productivity wheat_productivity, cluster( date ) bootcluster(state) reps(5000) seed(999)


areg ln_inc interact2 $macro_controls $agri_controls i.year, cluster(state) absorb(state)
outreg2 using chand_ddln.xls, replace  ctitle("Chand Marketing Reform") keep(interact2) addtext(State FE, YES, Year FE, YES, Demographic Controls, YES, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons



*******************************************************

clear

use "C:\Users\karti\Documents\Data\regressions\paper_2\data_for_regs.dta", clear


***DDD

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\productivity.dta"
drop _m

gen time=0
replace time = 2 if round==43
replace time=3 if round==50
replace time=4 if round==55 
replace time =5 if round==61
replace time=6 if round==64
replace time=7 if round==66 
replace time=8 if round==68



foreach var of varlist rice_productivity wheat_productivity wheat_procurement_proportion rice_procurement_proportion{
replace `var'=0 if `var'==.
}
global macro_controls "pop_full_new agrvad0405_crore"

global agri_controls "rice_prod wheat_prod no_agri_worker_united Wheat Rice wheat_procurement_proportion rice_procurement_proportion rice_productivity wheat_productivity"


gen fci_rice = (Rice>0)
gen fci_wheat = (Wheat>0)
gen fci_tot=(tot_procurement>0)

foreach var of varlist fci_rice fci_wheat fci_tot{

gen triple_1_`var' = interact1*`var'

gen triple_2_`var' = interact2*`var'

}

gen dum = fci_tot*post_dif

gen dum2_1 = fci_tot * marketing_reform

gen dum2_2 = fci_tot * chand_reform


egen ste = group(state)
gen ln_inc = ln(real_income_per_cult_1)

tab state, gen(nssstate)
gen t2 =  time - 1
forvalues j = 1/18 {
*linear
gen nsstate_`j'=nssstate`j'*t2
}

tabulate round, generate(yr)
** BOTH
areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year, cluster(state) absorb(state)
outreg2 using tripleln.xls, replace  ctitle("") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, NO, State Specific Linear Time Trend, NO) nocons


areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls, cluster(state) absorb(state)
outreg2 using tripleln.xls, append  ctitle("") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, YES, Agriculture Controls, NO, State Specific Linear Time Trend, NO) nocons


areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls, cluster(state) absorb(state)
outreg2 using tripleln.xls, append  ctitle("") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons


areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls i.state_id#c.year, cluster(state) absorb(state)
outreg2 using tripleln.xls, append  ctitle("") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, NO, State Specific Linear Time Trend, YES) nocons

cgmwildboot ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform yr* Rice Wheat pop_full_new agrvad0405_crore rice_prod wheat_prod no_agri_worker_united wheat_procurement_proportion rice_procurement_proportion rice_productivity wheat_productivity, cluster( date ) bootcluster(state) reps(5000) seed(999)

bootstrap rmse=e(rmse), reps(2000) seed(12345): areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls nsstate_*, cluster(state) absorb(state)




/*
bootstrap rmse=e(rmse), reps(750) seed(12345): areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls, cluster(state) absorb(state)
*/
*******
**Chand
areg ln_inc triple_2_fci_tot interact2 dum dum2_2 fci_tot chand_reform Rice Wheat i.year $macro_controls $agri_controls, cluster(state) absorb(state)
outreg2 using chand_ddln.xls, append  ctitle("") keep(triple_2_fci_tot interact2 dum dum2_2 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

** Excluding years

areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls if (date!=2004), cluster(state) absorb(state)
outreg2 using r_year_dropln.xls, replace  ctitle("2005") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls if (date!=2005), cluster(state) absorb(state)
outreg2 using r_year_dropln.xls, append  ctitle("2008") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls if (date!=2006), cluster(state) absorb(state)
outreg2 using r_year_dropln.xls, append  ctitle("2010") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls if (date!=2007), cluster(state) absorb(state)
outreg2 using r_year_dropln.xls, append  ctitle("2012") keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

****
**excluding states
forval x = 1/18{
areg ln_inc triple_1_fci_tot interact1 dum dum2_1 fci_tot marketing_reform Rice Wheat i.year $macro_controls $agri_controls if(ste!=`x'), cluster(state) absorb(state)
outreg2 using r_stateln.xls, append  ctitle("Excluding" `x') keep(triple_1_fci_tot interact1 dum dum2_1 fci_tot Rice Wheat rice_prod wheat_prod) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons
}


**year dummies

********************************************
*parallel trends

*******************************************************

clear



import excel "C:\Users\karti\Documents\Data\regressions\reform_status.xlsx", sheet("Sheet1") firstrow

replace date=0 if date==.


merge 1:m state using "C:\Users\karti\Documents\Data\regressions\all_agri_data_CPI_2004_05.dta"


keep if _m==3
drop _m

gen real_income_per_cult_1 = (real_farm_1_crore*10000000)/cultivators_united

keep if real_income_per_cult_1!=.

keep if year<2005

egen tr = group(year)
egen state_id = group(state)

gen post_dif = (year>=date)

gen t = tr*post_dif

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\DBcontrols.dta"
drop if _m==1
drop _m

gen ln_inc = ln(real_income_per_cult_1)


areg real_income_per_cult_1 t lnsdp otrev_pop ontrev_pop i.state_id, cluster(state) absorb(state)

areg ln_inc t lnsdp otrev_pop ontrev_pop, cluster(state) absorb(state)
outreg2 using parallel_final.xls, replace  ctitle("") keep(t) addtext(State FE, YES, Macro Controls, YES) nocons













areg real_income_per_cult_1 t lnsdp otrev_pop ontrev_pop, cluster(state) absorb(state)
outreg2 using parallel_1.xls, replace ctitle("") keep(real_income_per_cult_1) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons

areg real_income_per_cult_1 t lnsdp otrev_pop ontrev_pop, cluster(state) absorb(state)
outreg2 using parallel_1.xls, append  ctitle("") keep(real_income_per_cult_1) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, YES, State Specific Linear Time Trend, NO) nocons





** Placebo


clear

import delimited C:\Users\karti\Documents\Data\regressions\population_full.csv

save "C:\Users\karti\Documents\Data\regressions\population_control.dta", replace

clear

import delimited using "C:\Users\karti\Documents\Data\regressions\all_agri_data_CPI_2004_05.csv"

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\procurement_production.dta"

keep if _m==3

drop _m

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\population_control.dta"

keep if _m==3

drop _m

gen real_income_per_cult_1 = (real_farm_1_crore*10000000)/(cultivators_united)


merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\DBcontrols.dta"
drop if _m==1
drop _m



cd "C:\Users\karti\Documents\Data\regressions\paper_2"

gen post_dif = (year>=date)

gen interact1 = 0
replace interact1 = marketing_reform*post_dif




tab state, gen(st)
gen t1 =  year - 2000
forvalues j = 1/18 {
*linear
gen st_`j'=st`j'*t1
}

gen interact2 = 0
replace interact2=chand_reform*post_dif

egen state_id = group(state)



save "C:\Users\karti\Documents\Data\regressions\paper_2\data_for_regs.dta", replace

merge 1:1 state year using "C:\Users\karti\Documents\Data\regressions\paper_2\productivity.dta"
drop _m


gen fci_tot=(tot_procurement>0)

foreach var of varlist rice_productivity wheat_productivity wheat_procurement_proportion rice_procurement_proportion{
replace `var'=0 if `var'==.
}
global macro_controls "pop_full_new agrvad0405_crore"

global agri_controls "rice_prod wheat_prod no_agri_worker_united Wheat Rice wheat_procurement_proportion rice_procurement_proportion rice_productivity wheat_productivity"

gen ln_inc = ln(real_income_per_cult_1)


keep if year<2008

gen post = (year==2005)

gen interact_pt1 = 0
replace interact_pt1 = marketing_reform*post

gen interact_pt2 = 0
replace interact_pt2 = chand_reform*post


areg ln_inc interact_pt1 $macro_controls i.year, cluster(state) absorb(state)
outreg2 using placeboln.xls, replace  ctitle("") keep(interact_pt1) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, NO, State Specific Linear Time Trend, NO) nocons


areg ln_inc interact_pt2 $macro_controls $agri_controls i.year, cluster(state) absorb(state)
outreg2 using placeboln.xls, append  ctitle("") keep(interact_pt2) addtext(State FE, YES, Year FE, YES, Demographic Controls, NO, Agriculture Controls, NO, State Specific Linear Time Trend, NO) nocons


**********************************


